﻿using B.S.BasicData.Api.Write.Application.Command.Accout;
using B.S.BasicData.Api.Write.Application.Command.GridPerson;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Write.Controllers
{
    /// <summary>
    /// 账号控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        private readonly IMediator mediator;

        public AccountController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 创建管理员账号的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateAccount(CreateAccountCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 更新管理员账号的接口
        /// </summary>
        /// <param name="request">要更新的数据</param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateAccount(UpdateAccountCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除管理员账号的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelAccount(DelAccountCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 添加网格人员
        /// </summary>
        /// <param name="request">添加网格命令参数</param>
        /// <returns>响应包装类</returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateGridPerson(CreateGridPersonCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新网格人员
        /// </summary>
        /// <param name="request">参数命令</param>
        /// <returns>响应包装类</returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateGridPerson(UpdateGridPersonCommand request)
        {

            return mediator.Send(request);
        }
        /// <summary>
        /// 逻辑网格人员
        /// </summary>
        /// <param name="request">参数命令</param>
        /// <returns>响应包装类</returns>
        [HttpPut]
        public Task<ApiResult<int>> DelGridPerson(DelGridPersonCommand request)
        {
            return mediator.Send(request);
        }
    }
}
